<?php
class conn_database{
	private $HostName;
	private $HostUser;
	private $HostPassword;
	private $DatabaseName;
	private $Charset;
	function __construct($HostName,$HostUser,$HostPassword,$DatabaseName,$Charset){
		$this->HostName=$HostName;
		$this->HostUser=$HostUser;
		$this->HostPassword=$HostPassword;
		$this->DatabaseName=$DatabaseName;
		$this->Charset=$Charset;
		$this->connect();		
	}  //初始化连接
	function connect(){		
		$link=@mysql_connect($this->HostName,$this->HostUser,$this->HostPassword) or die ($this->sys_error()); //连接数据库服务器
		@mysql_select_db($this->DatabaseName,$link) or die (mysql_error());//选择数据库
		mysql_query("set names '".$this->Charset."'"); //连接编码方式
	}
	function db_close(){
		return mysql_close();
		}
	function sys_error(){
		echo"ERROR NO.".mysql_errno().":".mysql_error();
	}
}
?>